package com.agentworkflow.engine.core.model;

import com.agentworkflow.engine.core.enums.ElementType;
import com.agentworkflow.engine.core.model.node.FlowNode;
import lombok.Data;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Data
@ToString
public abstract class FlowElement {

    protected String id;

    protected String name;

    protected String description;

    protected int x = 0;

    protected int y = 0;

    protected List<String> connections = new ArrayList<>();

    public FlowElement(String id, String name, String description) {
        this.id = id;
        this.name = name;
        this.description = description;
    }

    public abstract ElementType getElementType();

    protected Map<String, Object> properties = new ConcurrentHashMap<>();

    public Object getProperty(String key) {
        return properties.get(key);
    }

    public void setProperty(String key, Object value) {
        properties.put(key, value);
    }

    public void clearProperties() {
        properties.clear();
    }

    public void addConnection(String id) {
        connections.add(id);
    }
}
